<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>dc-example</title>
    <script src="/libs/dc-sdk/dc.min.js"></script>
    <script src="../dat.gui.min.js"></script>
    <link href="/libs/dc-sdk/dc.min.css" type="text/css" rel="stylesheet" />
    <link href="../index.css" type="text/css" rel="stylesheet" />
  </head>

  <body>
    <div id="viewer-container" class="viewer-container"></div>

    <script>
      DC.config.baseUrl = '../libs/dc-sdk/resources/'
      let viewer = new DC.Viewer('viewer-container')
      let baseLayer = DC.ImageryLayerFactory.createImageryLayer(
        DC.ImageryType.AMAP,
        {
          style: 'img',
          crs: 'WGS84',
        }
      )
      viewer.addBaseLayer(baseLayer)

      let layer = new DC.TilesetLayer('layer').addTo(viewer)
      let tileset = new DC.Tileset(
        '//resource.dvgis.cn/data/3dtiles/dayanta/tileset.json'
      )
      tileset.setHeight(-420)
      tileset.setSplitDirection(-1)
      layer.addOverlay(tileset)
      viewer.sceneSplit.enable = true

      viewer.sceneSplit.addBaseLayer(
        DC.ImageryLayerFactory.createImageryLayer(DC.ImageryType.AMAP, {
          crs: 'WGS84',
        })
      )

      let tileset_right = new DC.Tileset(
        '//resource.dvgis.cn/data/3dtiles/dayanta/tileset.json'
      )
      tileset_right.setStyle(
        new DC.TilesetStyle({
          color: {
            conditions: [['true', 'rgba(255,255,0,0.8)']],
          },
        })
      )
      tileset_right.setHeight(-420)
      tileset_right.setSplitDirection(1)
      viewer.sceneSplit.addTileset(tileset_right)
      viewer.flyTo(tileset)
      let controls = {
        enable: true,
      }
      let gui = new dat.GUI()
      gui.add(controls, 'enable').onChange((value) => {
        viewer.sceneSplit.enable = value
      })
    </script>
  </body>
</html>
